package iotest;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;

//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.FileOutputStream;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class FileToFile {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		File f1 = new File("d://test//b.txt");
		File f2 = new File("d://test//c.txt");
		/*
		 * FileInputStream fis = new FileInputStream(f1); try { FileOutputStream
		 * fos = new FileOutputStream(f2); try { byte[] bs = new byte[1024]; int
		 * length; while ((length = fis.read(bs)) > 0) { fos.write(bs); } }
		 * finally { fos.close(); } } finally { fis.close(); }
		 */
		BufferedReader br = new BufferedReader(new FileReader(f1));

		PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(f2,
				true)));

		char[] cs = new char[1024];
		int length;

		while ((length = br.read(cs)) > 0) {
			pw.write(cs, 0, length);

		}
		pw.close();
		br.close();
	}
}
